<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>for 遍历数组</title>
</head>
<body>
<div id="app">
    <!--  直接显示整个数组内容  -->
    <div>{{ nameList }}</div>

    <!--  显示指定的数组元素  -->
    <div>{{ nameList[0] }}</div>
    <div>{{ nameList[1] }}</div>
    <div>{{ nameList[2] }}</div>
    <div>{{ nameList[3] }}</div>
    <br>

    <!--  显示指定的数组元素——循环写法  -->
    <div v-for="name in nameList">{{  name }}</div>


    <ol>
        <li v-for="name in nameList">{{ name }}</li>
    </ol>

    <ul>
        <li v-for="(name, index) in nameList">{{ index }}. {{ name }}</li>
    </ul>

</div>

<script type="module">
    import {createApp, ref} from "../../../../../js/vue.esm-browser.js";

    const app = createApp({
        setup() {
            let nameList = ref(["Jim", "James", "Kevin", "Kobe"])
            return {
                nameList,
            }
        }
    })

    app.mount("#app")
</script>
</body>
</html>